package com.hl.sfzy.controller;


import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

@RestController
public class FileController {
    @GetMapping("/down")
    public void down(HttpServletResponse response ,String file) throws IOException {
        File filepath = new File(file);
        ServletOutputStream outputStream = response.getOutputStream();
        FileInputStream fileInputStream = new FileInputStream(filepath);
        FileCopyUtils.copy(fileInputStream,outputStream);
    }

}
